package modules.lock.lock2;

import modules.lock.synchronized1.Ticket1;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * 卖票案例 - Lock的 lock
 * Ticket1 是 资源类
 * @author shengren.yan
 * @create 2021-03-05
 */
@SpringBootTest
public class Lock2 {

    @Test
    void test() {
        Ticket1 ticket = new Ticket1();

        new Thread(()->{ for(int i=0;i<=40;i++){ ticket.doTicket();}},"A").start();
        new Thread(()->{ for(int i=0;i<=40;i++){ ticket.doTicket();}},"B").start();
        new Thread(()->{ for(int i=0;i<=40;i++){ ticket.doTicket();}},"C").start();
        new Thread(()->{ for(int i=0;i<=40;i++){ ticket.doTicket();}},"D").start();
    }

}
